<?php
       /* 查询页所有方法 
        * @writeTime 2020.6.3
        * @autor huangchuting
        * 
        * */

        require_once 'config.php';
        
        /* 根据条件模糊查询书名,作者相同或相似的书本
         * @param searchNew
         * @return array*rows
         *  */
        
        function fuzzyBook($searchNew){
            $sqlGet="SELECT * FROM book WHERE bookName LIKE '%$searchNew%'
                    UNION SELECT * FROM book WHERE writer LIKE '%$searchNew%'";
            $result=getQuery($sqlGet);
            return $result; 
        }

        
        /* 根据条件模糊查询评论相关的书评
         * @param searchNew
         * @return array*rows
         *  */
        function fuzzyReview($searchNew){
            $sqlGet="SELECT * FROM Review,User WHERE Review.uId=User.uId AND title LIKE '%$searchNew%'";
            $result=getQuery($sqlGet);
            return $result;
        }
        
        /* 根据书评标签查找书评
         * @param searchNew
         * @return array*rows
         *  */
        function fuzzyLabel($searchNew){
            $sqlGet="SELECT * FROM Review,User,Label WHERE  Review.uId=User.uId AND Review.labelId=Label.labelId AND label LIKE '%$searchNew%' ";
            $result=getQuery($sqlGet);
            return $result;
        }
        
        /* 根据作者名字查找作者 和作者作品
         * @param searchNew
         * @return array*row
         *  */
        function  fuzzyWriter($searchNew){
            $sqlGet="SELECT * FROM Hot_writer WHERE  writer LIKE '%$searchNew%' ";
            $result=getQuery($sqlGet);
            return $result;
        }
        
        function writerWork($writerId){
            $sqlGet="SELECT * FROM works WHERE writerId ='$writerId' ";
            $result=getQuery($sqlGet);
            return $result;
        }
        
       
/*         $result=fuzzyWriter("迅");
        var_dump($result);
        $result=writerWork("7");
        var_dump($result); */
        
?>